import { REPLY_TYPE } from '@/enum/dynamic';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { BaseEntity } from './base.entity';
import { User } from './user.entity';

/**
 * 用户评论表
 */
@Entity('dynamic_reply')
export class DynamicReply extends BaseEntity {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'id',
    comment: '主键，自增',
  })
  id: number;

  @Column({
    type: 'int',
    name: 'type',
    comment: `
      回复类型，
      1为回复评论
      2为回复回复
    `,
  })
  type: REPLY_TYPE;

  @Column({
    type: 'int',
    name: 'reply_user_id',
    comment: '回复人的id',
  })
  replyUserId: number;

  userInfo: User;

  @Column({
    type: 'int',
    name: 'reply_target_id',
    comment: '被回复对象的id（评论/回复）',
  })
  replyTargetId: number;

  @Column({
    type: 'int',
    name: 'reply_target_user_id',
    comment: '被回复对象的人的id（评论/回复）',
  })
  replyTargetUserId: number;

  replyTargetUserInfo: User;

  @Column({
    type: 'int',
    name: 'dynamic_id',
    comment: '所属动态id',
  })
  dynamicId: number;

  @Column({
    type: 'int',
    name: 'comment_id',
    comment: '所属评论id',
  })
  commentId: number;

  @Column({
    type: 'varchar',
    name: 'content',
    comment: '回复内容',
  })
  content: string;
}
